package com.example.hasee.zhcd.Adapters;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

import com.example.hasee.zhcd.Activities.ChuanWu.NearDetailActivity;
import com.example.hasee.zhcd.Activities.ChuanWu.NearPointActivity;
import com.example.hasee.zhcd.R;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by hasee on 2017/9/20.
 */

public class NearEntrustAdapter extends BaseExpandableListAdapter {
    private ArrayList<HashMap<String, String>> list;
    private ArrayList<ArrayList<String>> son_list;
    private Context context;
    private Holder holder;

    public NearEntrustAdapter(Context context, ArrayList<HashMap<String, String>> list, ArrayList<ArrayList<String>> son_list) {
        this.context = context;
        this.list = list;
        this.son_list = son_list;
    }

    @Override
    public int getGroupCount() {
        return list.size();
    }

    @Override
    public int getChildrenCount(int i) {
        return son_list.get(i).size();
    }

    @Override
    public Object getGroup(int i) {
        return list.get(i);
    }

    @Override
    public Object getChild(int i, int i1) {
        return son_list.get(i).get(i1);
    }

    @Override
    public long getGroupId(int i) {
        return 0;
    }

    @Override
    public long getChildId(int i, int i1) {
        return 0;
    }

    @Override
    public boolean hasStableIds() {
        return true;
    }

    @Override
    public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {
        Holder holder;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.near_entrust_item, null);
            holder = new Holder();
            holder.fwbsx = (TextView) view.findViewById(R.id.fwbsx);
            holder.ftzr = (TextView) view.findViewById(R.id.ftzr);
            holder.ftzsj = (TextView) view.findViewById(R.id.ftzsj);
            view.setTag(holder);
        } else {
            holder = (Holder) view.getTag();
        }
        holder.fwbsx.setText((String) list.get(i).get("fwtsx"));
        holder.ftzr.setText((String) list.get(i).get("ftzr"));
        holder.ftzsj.setText((String) list.get(i).get("ftzsj"));
        return view;
    }

    @Override
    public View getChildView(int i, int i1, boolean b, View view, ViewGroup viewGroup) {
        SonHolder sonHolder;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.leaveportentrust_list_item_son, null);
            sonHolder = new SonHolder();
            sonHolder.content = (TextView) view.findViewById(R.id.content);
            view.setTag(sonHolder);
        } else {
            sonHolder = (SonHolder) view.getTag();
        }
        if (son_list.get(i).get(i1).length() == 0) {
            sonHolder.content.setText("暂无通知内容");
        } else {
            sonHolder.content.setText(son_list.get(i).get(i1));
        }

        return view;
    }

    @Override
    public boolean isChildSelectable(int i, int i1) {
        return true;
    }

//    @Override
//    public int getCount() {
//        return list.size();
//    }
//
//    @Override
//    public Object getItem(int position) {
//        return null;
//    }
//
//    @Override
//    public long getItemId(int position) {
//        return 0;
//    }
//
//    @Override
//    public View getView(final int position, View convertView, ViewGroup parent) {
//        if (convertView == null) {
//            holder = new Holder();
//            convertView = itemInflater.inflate(R.layout.near_entrust_item, null);
//            holder.ftznr = (TextView) convertView.findViewById(R.id.ftznr);
//            holder.fwtsx = (TextView) convertView.findViewById(R.id.fwbsx);
//            holder.ftzr = (TextView) convertView.findViewById(R.id.ftzr);
//            holder.ftzsj = (TextView) convertView.findViewById(R.id.ftzsj);
//            convertView.setTag(holder);
//        } else {
//            holder = (Holder) convertView.getTag();
//        }
//        holder.ftznr.setText((String) list.get(position).get("ftznr"));
//        holder.fwtsx.setText((String) list.get(position).get("fwtsx"));
//        holder.ftzr.setText((String) list.get(position).get("ftzr"));
//        holder.ftzsj.setText((String) list.get(position).get("ftzsj"));
//        return convertView;
//    }

    class Holder {
        private TextView fwbsx;
        private TextView ftzr;
        private TextView ftzsj;
    }
    class SonHolder {
        private TextView content;
    }
}
